<?php
/**
 * Created by PhpStorm.
 * User: lenove
 * Date: 2018/12/10
 * Time: 19:09
 */
include "../config.php";
include "../Status.php";
if($_SERVER["REQUEST_METHOD"] != "POST"){
    print_r(json_encode(Status::$request_error));
    return;
}
if(isset($_REQUEST["uname"]) && isset($_REQUEST["upwd"])){
    $UNAME = $_REQUEST["uname"];
    $UPWD = $_REQUEST["upwd"];
    $sql = "SELECT `id`,`uname` FROM userinfo WHERE uname = ? AND upwd=?;";
    $stmt = $conn->prepare($sql);
    $stmt->bind_param("ss", $UNAME, $UPWD);
    $stmt->execute();
    $resultArr=$stmt->get_result();
    if($resultArr->num_rows>=1){
        Status::$login_success["data"]=$resultArr->fetch_assoc();
        print_r(json_encode(Status::$login_success));
    }else{
        print_r(json_encode(Status::$login_failure));
    }
    $stmt->close();
    $conn->close();
} else {
    print_r(json_encode(Status::$login_error));
}